package GUI;

import java.awt.Color;

import javax.swing.*;

import handlers.ColourSchema;
import handlers.SectionManager;
import handlers.ListManager;
import handlers.PopupManager;

public class MainFrame extends JFrame {

    private static final long serialVersionUID = 1L;
    
    //Colours
  	Color primary;
  	Color secondary;
  	Color selected;
  	
  	//Current Section
  	String current;
  	
  	//Tools
  	SectionManager sectionMng;
  	ListManager listMng;
  	PopupManager popups;
  	ColourSchema colours;
    
    public MainFrame() {
    	//init colours
    	colours = new ColourSchema();
    	primary = colours.getPrimary();
    	secondary = colours.getSecondary();
    	selected = colours.getSelected();
    	
    	sectionMng = new SectionManager(this);
    	listMng = new ListManager();
    	popups = new PopupManager();
    	
    	initComponents();
    	sectionMng.setHeaderComps();
    }
    
    //TODO getters
    public JButton getBtnX(int num) {
    	switch (num) {
    	case 1:
    		return btn1;
    	case 2:
    		return btn2;
    	case 3:
    		return btn3;
    	case 4:
       		return btn4;
    	case 5:
    		return btn5;
    	case 6:
    		return btn6;
    	case 7:
    		return btn7;
    	default:
    		return null;
    	}
    }
    public JMenu[] getToggleMenu(String user) {
    	JMenu[] result = new JMenu[2];
    	if (!(user.equals("super_caja") || user.equals("cfo") || user.equals("admin"))) {
    		result[0] = caja;
    	}
    	if (!(user.equals("ventas") || user.equals("cfo") || user.equals("admin"))) {
    		result[1] = local;
    	}
    	return result;
    }
    public JLabel[] getHeader() {
    	return pos;
    }
    public JLabel[] getFooterLabels() {
    	JLabel[] foot = {cntFooter, itemNumFooter, totalSales, totalSalesNum};
    	return foot;
    }
    public JButton getFooterBtn() {
    	return cobrarBtn;
    }
    public String getCurrentSection() {
    	return current;
    }
    public JPanel getList() {
    	return scrollColour;
    }
    public void initCurrentSection(String cs) {
    	current = cs;
    }
    
    //TODO Switchers
    public void setCurrentHeader(String head) {
    	sectionMng.displayHeader(head);
    	current = head;
    }
    public void setUserRole(String r) {
    	role.setText(r);
    }


    //TODO init
    private void initComponents() {
        //UserPane
        userPane = new JPanel();
        usuarioFixed = new JLabel();
        role = new JLabel();
        username = new JLabel();
        logout = new javax.swing.JButton();
        //ListPane
        listPane = new JPanel();
        search = new JTextField();
        addBtn = new JButton();
        searchBtn = new JButton();
        //List-Content
        content = new JPanel();
        scrollList = new JScrollPane();
        scrollColour = new JPanel();
        //Title
        titlePane = new JPanel();
        text = new JLabel();
        //Copyright
        copyright = new JPanel();
        copyrightText = new JLabel();
        //Options
        options = new JPanel();
        btn1 = new JButton();
        btn2 = new JButton();
        btn3 = new JButton();
        btn4 = new JButton();
        btn5 = new JButton();
        btn6 = new JButton();
        btn7 = new JButton();
        //Menu
        menu = new javax.swing.JMenuBar();
        archivo = new javax.swing.JMenu();
        quit = new javax.swing.JMenuItem();
        local = new javax.swing.JMenu();
        cambiarLocal = new javax.swing.JMenuItem();
        caja = new javax.swing.JMenu();
        acCaja = new javax.swing.JMenuItem();
        saveState = new javax.swing.JMenuItem();
        descuentos = new javax.swing.JMenuItem();
        info = new javax.swing.JMenu();
        about = new javax.swing.JMenuItem();
        help = new javax.swing.JMenuItem();
        

        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Tiliches");
        getContentPane().setBackground(Color.WHITE);
        setFont(new java.awt.Font("Open Sans", 0, 18)); // NOI18N
        
        //TODO USER PANE
        userPane.setBackground(secondary);

        usuarioFixed.setFont(new java.awt.Font("Open Sans", 1, 18)); // NOI18N
        usuarioFixed.setText("Usuario:");

        role.setFont(new java.awt.Font("Open Sans", 0, 18)); // NOI18N
        role.setText("role");

        username.setFont(new java.awt.Font("Open Sans", 0, 18)); // NOI18N
        username.setText("Name LastName");

        logout.setBackground(new java.awt.Color(219, 0, 0));
        logout.setForeground(new java.awt.Color(255, 255, 255));
        logout.setText("Logout");
        logout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout userPaneLayout = new javax.swing.GroupLayout(userPane);
        userPane.setLayout(userPaneLayout);
        userPaneLayout.setHorizontalGroup(
            userPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(userPaneLayout.createSequentialGroup()
                .addGroup(userPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(userPaneLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(usuarioFixed)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(username)
                        .addGap(0, 103, Short.MAX_VALUE))
                    .addGroup(userPaneLayout.createSequentialGroup()
                        .addGap(84, 84, 84)
                        .addComponent(role)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(logout, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        userPaneLayout.setVerticalGroup(
            userPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, userPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(userPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(userPaneLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(logout))
                    .addGroup(userPaneLayout.createSequentialGroup()
                        .addGroup(userPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(usuarioFixed)
                            .addComponent(username))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(role, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );

        
        
        //TODO LIST PANE
        listPane.setBackground(secondary);

        search.setText("Search");
        search.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchActionPerformed(evt);
            }
        });

        addBtn.setText("+");
        addBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addBtnActionPerformed(evt);
            }
        });

        searchBtn.setText("S");
        searchBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchBtnActionPerformed(evt);
            }
        });
        
        //TODO Content
        content.setBackground(secondary);

        scrollList.setBackground(secondary);

        scrollColour.setBackground(secondary);

        BoxLayout scrollColourLayout = new javax.swing.BoxLayout(scrollColour, BoxLayout.Y_AXIS);
        scrollColour.setLayout(scrollColourLayout);

        scrollList.setViewportView(scrollColour);
        
        initContent();

        GroupLayout listPaneLayout = new GroupLayout(listPane);
        listPane.setLayout(listPaneLayout);
        listPaneLayout.setHorizontalGroup(
            listPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(listPaneLayout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(search, GroupLayout.PREFERRED_SIZE, 737, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(addBtn, GroupLayout.PREFERRED_SIZE, 53, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(searchBtn, GroupLayout.PREFERRED_SIZE, 52, GroupLayout.PREFERRED_SIZE)
                .addContainerGap(134, Short.MAX_VALUE))
            .addGroup(listPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(content, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        listPaneLayout.setVerticalGroup(
            listPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(listPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(listPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(search, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
                    .addComponent(addBtn)
                    .addComponent(searchBtn))
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(content, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        
        //TODO TITLE
        titlePane.setBackground(primary);

        text.setFont(new java.awt.Font("Poiret One", 0, 48)); // NOI18N
        text.setForeground(Color.WHITE);
        text.setText("Tiliches");

        GroupLayout titlePaneLayout = new GroupLayout(titlePane);
        titlePane.setLayout(titlePaneLayout);
        titlePaneLayout.setHorizontalGroup(
            titlePaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(titlePaneLayout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(text)
                .addContainerGap(24, Short.MAX_VALUE))
        );
        titlePaneLayout.setVerticalGroup(
            titlePaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(titlePaneLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(text, GroupLayout.PREFERRED_SIZE, 65, GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        //TODO COPYRIGHT
        copyright.setBackground(primary);

        copyrightText.setFont(new java.awt.Font("Poiret One", 1, 18)); // NOI18N
        copyrightText.setForeground(Color.WHITE);
        copyrightText.setText("(C) Sofie Chaves 2014.");
        copyrightText.setToolTipText("");

        GroupLayout copyrightLayout = new GroupLayout(copyright);
        copyright.setLayout(copyrightLayout);
        copyrightLayout.setHorizontalGroup(
            copyrightLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(copyrightLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(copyrightText)
                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        copyrightLayout.setVerticalGroup(
            copyrightLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(copyrightText, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
        );

        //TODO OPTIONS
        options.setBackground(Color.WHITE);

        btn1.setBackground(primary);
        btn1.setFont(new java.awt.Font("Open Sans", 0, 36)); // NOI18N
        btn1.setForeground(Color.WHITE);
        btn1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn1ActionPerformed(evt);
            }
        });

        btn2.setBackground(primary);
        btn2.setFont(new java.awt.Font("Open Sans", 0, 36)); // NOI18N
        btn2.setForeground(Color.WHITE);
        btn2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn2ActionPerformed(evt);
            }
        });

        btn3.setBackground(primary);
        btn3.setFont(new java.awt.Font("Open Sans", 0, 36)); // NOI18N
        btn3.setForeground(Color.WHITE);
        btn3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn3ActionPerformed(evt);
            }
        });

        btn4.setBackground(primary);
        btn4.setFont(new java.awt.Font("Open Sans", 0, 36)); // NOI18N
        btn4.setForeground(Color.WHITE);
        btn4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn4ActionPerformed(evt);
            }
        });

        btn5.setBackground(primary);
        btn5.setFont(new java.awt.Font("Open Sans", 0, 36)); // NOI18N
        btn5.setForeground(Color.WHITE);
        btn5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn5ActionPerformed(evt);
            }
        });

        btn6.setBackground(primary);
        btn6.setFont(new java.awt.Font("Open Sans", 0, 36)); // NOI18N
        btn6.setForeground(Color.WHITE);
        btn6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn6ActionPerformed(evt);
            }
        });

        btn7.setBackground(primary);
        btn7.setFont(new java.awt.Font("Open Sans", 0, 36)); // NOI18N
        btn7.setForeground(Color.WHITE);
        btn7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn7ActionPerformed(evt);
            }
        });

        GroupLayout optionsLayout = new GroupLayout(options);
        options.setLayout(optionsLayout);
        optionsLayout.setHorizontalGroup(
            optionsLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(optionsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(optionsLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(btn1, GroupLayout.PREFERRED_SIZE, 249, GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn2, GroupLayout.PREFERRED_SIZE, 249, GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn3, GroupLayout.PREFERRED_SIZE, 249, GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn4, GroupLayout.PREFERRED_SIZE, 249, GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn5, GroupLayout.PREFERRED_SIZE, 249, GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn6, GroupLayout.PREFERRED_SIZE, 249, GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn7, GroupLayout.PREFERRED_SIZE, 249, GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        optionsLayout.setVerticalGroup(
            optionsLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(optionsLayout.createSequentialGroup()
                .addComponent(btn1)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn2)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn3)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn4)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn5)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn6)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btn7)
                .addContainerGap())
        );

        initMenu();
        
        GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(copyright, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(titlePane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(userPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(listPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(options, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
                        .addGap(10, 22, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(userPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .addGap(26, 26, 26)
                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(options, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(listPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(titlePane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addComponent(copyright, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addGap(5, 5, 5))
        );
        
        pack();
    }
    //TODO Menu
    private void initMenu() {
    	archivo.setText("Archivo");

        quit.setText("Cerrar Programa");
        archivo.add(quit);
        quit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quitActionPerformed(evt);
            }
        });

        menu.add(archivo);
        
        local.setText("Local");

        cambiarLocal.setText("Cambiar Local");
        cambiarLocal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cambiarlocalActionPerformed(evt);
            }
        });
        local.add(cambiarLocal);

        menu.add(local);

        caja.setText("Caja");

        acCaja.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.SHIFT_MASK));
        acCaja.setText("Abrir/Cerrar Caja");
        acCaja.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                acCajaActionPerformed(evt);
            }
        });
        caja.add(acCaja);

        saveState.setText("Guardar estado de caja");
        caja.add(saveState);

        descuentos.setText("Descuentos");
        descuentos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                descuentosActionPerformed(evt);
            }
        });
        caja.add(descuentos);

        menu.add(caja);

        info.setText("Informacion");

        about.setText("Acerca de");
        about.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aboutActionPerformed(evt);
            }
        });
        info.add(about);

        help.setText("Ayuda");
        info.add(help);

        menu.add(info);

        setJMenuBar(menu);
    }
    
    
	//TODO Content
    private void initContent() {
    	//Sales Footer
		salesFooter = new JPanel();
		cntFooter = new JLabel();
		itemNumFooter = new JLabel();
		cobrarBtn = new JButton();
		totalSales = new JLabel();
		totalSalesNum = new JLabel();
		//Header
		header = new JPanel();
		pos = new JLabel[5];
		for(int i=0; i<5; ++i) {
			pos[i] = new JLabel();
		}

		salesFooter.setBackground(Color.WHITE);

		cntFooter.setFont(new java.awt.Font("Open Sans", 0, 14)); // NOI18N
		cntFooter.setText("Cnt Items:");

		itemNumFooter.setText("900");

		cobrarBtn.setBackground(primary);
		cobrarBtn.setForeground(Color.WHITE);
		cobrarBtn.setText("Cobrar");
		cobrarBtn.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				cobrarBtnActionPerformed(evt);
			}
		});

		totalSales.setFont(new java.awt.Font("Open Sans", 0, 18)); // NOI18N
		totalSales.setText("Total:");

		totalSalesNum.setBackground(Color.WHITE);
		totalSalesNum.setFont(new java.awt.Font("Open Sans", 1, 24)); // NOI18N
		totalSalesNum.setForeground(primary);
		totalSalesNum.setText("$18.00");

		GroupLayout salesFooterLayout = new GroupLayout(salesFooter);
		salesFooter.setLayout(salesFooterLayout);
		salesFooterLayout.setHorizontalGroup(
				salesFooterLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addGroup(salesFooterLayout.createSequentialGroup()
						.addContainerGap()
						.addGroup(salesFooterLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
								.addGroup(salesFooterLayout.createSequentialGroup()
										.addComponent(cntFooter)
										.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(itemNumFooter)
										.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
										.addComponent(totalSales))
										.addComponent(cobrarBtn))
										.addGap(18, 18, 18)
										.addComponent(totalSalesNum)
										.addGap(22, 22, 22))
				);
		salesFooterLayout.setVerticalGroup(
				salesFooterLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addGroup(salesFooterLayout.createSequentialGroup()
						.addGroup(salesFooterLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
								.addGroup(salesFooterLayout.createSequentialGroup()
										.addGroup(salesFooterLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
												.addGroup(salesFooterLayout.createSequentialGroup()
														.addGap(14, 14, 14)
														.addComponent(totalSales))
														.addGroup(salesFooterLayout.createSequentialGroup()
																.addContainerGap()
																.addGroup(salesFooterLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
																		.addComponent(cntFooter)
																		.addComponent(itemNumFooter))))
																		.addGap(6, 6, 6)
																		.addComponent(cobrarBtn))
																		.addGroup(salesFooterLayout.createSequentialGroup()
																				.addGap(25, 25, 25)
																				.addComponent(totalSalesNum)))
																				.addContainerGap(15, Short.MAX_VALUE))
				);

		header.setBackground(Color.WHITE);

		pos[0].setFont(new java.awt.Font("Open Sans", 0, 18));
		pos[1].setFont(new java.awt.Font("Open Sans", 0, 18));
		pos[2].setFont(new java.awt.Font("Open Sans", 0, 18));
		pos[3].setFont(new java.awt.Font("Open Sans", 0, 18));
		pos[4].setFont(new java.awt.Font("Open Sans", 0, 18));

		GroupLayout headerLayout = new GroupLayout(header);
		header.setLayout(headerLayout);
		headerLayout.setHorizontalGroup(
				headerLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addGroup(headerLayout.createSequentialGroup()
						.addContainerGap()
						.addComponent(pos[0])
						.addGap(58, 58, 58)
						.addComponent(pos[1])
						.addGap(165, 165, 165)
						.addComponent(pos[2])
						.addGap(248, 248, 248)
						.addComponent(pos[3])
						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 145, Short.MAX_VALUE)
						.addComponent(pos[4])
						.addGap(49, 49, 49))
				);
		headerLayout.setVerticalGroup(
				headerLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addGroup(headerLayout.createSequentialGroup()
						.addContainerGap()
						.addGroup(headerLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
								.addComponent(pos[0])
								.addComponent(pos[1])
								.addComponent(pos[2])
								.addComponent(pos[3])
								.addComponent(pos[4]))
								.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
				);

		GroupLayout contentLayout = new GroupLayout(content);
		content.setLayout(contentLayout);
		contentLayout.setHorizontalGroup(
				contentLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addGroup(contentLayout.createSequentialGroup()
						.addContainerGap()
						.addGroup(contentLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
								.addComponent(scrollList, GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
								.addComponent(header, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
								.addComponent(salesFooter, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
								.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
				);
		contentLayout.setVerticalGroup(
				contentLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addGroup(contentLayout.createSequentialGroup()
						.addComponent(header, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
						.addComponent(scrollList, GroupLayout.PREFERRED_SIZE, 364, GroupLayout.PREFERRED_SIZE)
						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
						.addComponent(salesFooter, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
				);
    }
    //TODO Menu Action Listeners
    private void cambiarlocalActionPerformed(java.awt.event.ActionEvent evt) {
    	popups.showChangeLocale();
    }
    
    private void acCajaActionPerformed(java.awt.event.ActionEvent evt) {
    	popups.abrirCerrarCaja();
    }
    
    private void descuentosActionPerformed(java.awt.event.ActionEvent evt) {
    	
    }
    private void aboutActionPerformed(java.awt.event.ActionEvent evt) {
    	
    }
    private void quitActionPerformed(java.awt.event.ActionEvent evt) {
    	System.exit(0);
    }
    
    
    //TODO Button Action Listeners
    private void btn1ActionPerformed(java.awt.event.ActionEvent evt) {
    	btn1.setForeground(selected);
    	btn1.setEnabled(false);
    	current = btn1.getText().toLowerCase();
    	sectionMng.changeSection();
    	sectionMng.btnEnabler(2,3,4,5,6,7);
    }

    private void btn2ActionPerformed(java.awt.event.ActionEvent evt) {
    	btn2.setForeground(selected);
    	btn2.setEnabled(false);
    	current = btn2.getText().toLowerCase();
    	sectionMng.changeSection();
    	sectionMng.btnEnabler(1,3,4,5,6,7);
    }

    private void btn3ActionPerformed(java.awt.event.ActionEvent evt) {
    	btn3.setForeground(selected);
    	btn3.setEnabled(false);
    	current = btn3.getText().toLowerCase();
    	sectionMng.changeSection();
    	sectionMng.btnEnabler(1,2,4,5,6,7);
    }

    private void btn4ActionPerformed(java.awt.event.ActionEvent evt) {
    	btn4.setForeground(selected);
    	btn4.setEnabled(false);
    	current = btn4.getText().toLowerCase();
    	sectionMng.changeSection();
    	sectionMng.btnEnabler(1,2,3,5,6,7);
    }

    private void btn5ActionPerformed(java.awt.event.ActionEvent evt) {
    	btn5.setForeground(selected);
    	btn5.setEnabled(false);
    	current = btn5.getText().toLowerCase();
    	sectionMng.changeSection();
    	sectionMng.btnEnabler(1,2,3,4,6,7);
    }

    private void btn6ActionPerformed(java.awt.event.ActionEvent evt) {
    	btn6.setForeground(selected);
    	btn6.setEnabled(false);
    	current = btn6.getText().toLowerCase();
    	sectionMng.changeSection();
    	sectionMng.btnEnabler(1,2,3,4,5,7);
    }

    private void btn7ActionPerformed(java.awt.event.ActionEvent evt) {
    	btn7.setForeground(selected);
    	btn7.setEnabled(false);
    	current = btn7.getText().toLowerCase();
    	sectionMng.changeSection();
    	sectionMng.btnEnabler(1,2,3,4,5,6);
    }
    
    //TODO Fx buttons
    private void searchActionPerformed(java.awt.event.ActionEvent evt) {
    }
    private void searchBtnActionPerformed(java.awt.event.ActionEvent evt) {
    }
    
    private void addBtnActionPerformed(java.awt.event.ActionEvent evt) {
    	switch (current) {
    	case "ventas":
    		JPanel aux = listMng.createItem();
    		scrollColour.add(aux);
    		aux = listMng.addSpace();
    		scrollColour.add(aux);
    		scrollColour.validate();
    		scrollColour.repaint();
    		break;
    	case "inventario":
    		popups.showNewProduct();
    		break;
    	case "clientes":
    		popups.showNewClient();
    		break;
    	case "proveedores":
    		popups.showNewProv();
    		break;
    	case "tiendas":
    		popups.showNewStore();
    		break;
    	case "bodegas":
    		popups.showNewStorehouse();
    		break;
    	case "usuarios":
    		popups.showNewUser();
    		break;
    	}
    }
    private void cobrarBtnActionPerformed(java.awt.event.ActionEvent evt) {
	}
    
    private void logoutActionPerformed(java.awt.event.ActionEvent evt) {
    	handlers.WindowManager wm = new handlers.WindowManager();
    	wm.logout();
    }
    
    

    //TODO Variables declaration
    //UserPane
    private JPanel userPane;
    private JLabel username;
    private JLabel usuarioFixed;
    private JLabel role;
    private JButton logout;
        //ListPane
        private JPanel listPane;
        private JTextField search;
        private JButton searchBtn;
    private JButton addBtn;
    //List-Content
    private JPanel content;
    private JPanel scrollColour;
    private JScrollPane scrollList;
    //Footers
  		//Sales
  	private JPanel salesFooter;
  	private JLabel cntFooter;
  	private JLabel itemNumFooter;
  	private JButton cobrarBtn;
  	private JLabel totalSales;
  	private JLabel totalSalesNum;
  	//Header
  	private JPanel header;
  	private JLabel[] pos;
    //Title
    private JLabel text;
    private JPanel titlePane;
    //Copyright
    private JPanel copyright;
    private JLabel copyrightText;
    //Options
    private JPanel options;
    private JButton btn1;
    private JButton btn2;
    private JButton btn3;
    private JButton btn4;
    private JButton btn5;
    private JButton btn6;
    private JButton btn7;
    //Menu
    private javax.swing.JMenuBar menu;
    private JMenu archivo;
    private JMenuItem quit;
    private JMenu local;
    private JMenuItem cambiarLocal;
    private JMenu caja;
    private JMenuItem acCaja;
    private JMenuItem saveState;
    private JMenuItem descuentos;
    private JMenu info;
    private JMenuItem about;
    private JMenuItem help;
}